package com.usian.controller;

import com.usian.pojo.Emp;
import com.usian.pojo.User;
import com.usian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class ProviderController {
    @Autowired
    private UserService userService;

    @RequestMapping("user/{id}")
    public User getUser(@PathVariable Integer id){
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return userService.getUser(id);
    }

    @RequestMapping("/findall")
    public List<Emp> findall(){
        return userService.findall();
    }
    @RequestMapping("emp/{id}")
    public Emp getempbyeid(@PathVariable Integer id){
        return userService.findempbyeid(id);
    }
    @RequestMapping("emp1/{ename}")
    public List<Emp> getempbyename(@PathVariable String ename){
        return userService.findempbyename(ename);
    }
    @RequestMapping("/provider/user")
    public User getUser1(){
        /*try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
        return new User(1,"159",16);
    }
    @RequestMapping("/list/{nums}")
    public int[] findnums(@PathVariable int[] nums){
        return nums;
    }
    @RequestMapping("/user")
    public User finduser(@RequestBody User user){
        return user;
    }
    @RequestMapping("/id")
    Integer findid(@RequestParam int id){
        return id;
    }
}
